//
//  MyselfView.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/6/28.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "MyselfView.h"

@interface MyselfView ()


@property (nonatomic, weak)UIImageView * backImageView;

@property (nonatomic, weak)UIImageView * topImageView;

@property (nonatomic, weak)UIImageView * userIconImageView;

@property (nonatomic, weak)UILabel * accountLabel;

@property (nonatomic, weak)UILabel * emailLabel;

@property (nonatomic, weak)UIView * moneyView;

@property (nonatomic, weak)UILabel * allMoneyLabel;

@property (nonatomic, weak)UILabel * userMoneyLabel;

@property (nonatomic, weak)UILabel * allMoneyCountLabel;

@property (nonatomic, weak)UILabel * userMoneyCountLabel;

@property (nonatomic, weak)UIView * lineView;

@end

@implementation MyselfView


- (instancetype)initWithFrame:(CGRect)frame{
    
    if ([super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return self;
}





- (void)setupUI{
    
    UIImageView * backImageView = [[UIImageView alloc] init];
    
    backImageView.backgroundColor = [UIColor whiteColor];
    backImageView.image = [UIImage imageNamed:@"背景"];
    
    self.backImageView = backImageView;
    
    [self addSubview:self.backImageView];
    
    
    UIImageView * topImageView = [[UIImageView alloc] init];
    
    topImageView.image = [UIImage imageNamed:@"头部"];
    
    self.topImageView = topImageView;
    
    [self addSubview:self.topImageView];
    
    
    UIImageView * userIconImageView = [[UIImageView alloc] init];
    
    userIconImageView.image = [UIImage imageNamed:@"默认头像"];
    
    self.userIconImageView = userIconImageView;
    
    [self addSubview:self.userIconImageView];
    
    
    UILabel * accountLabel = [UILabel new];
    
    accountLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    accountLabel.textColor = ColorWithRGB(0xbebebe);
    accountLabel.text = @"12345678987";
    
    self.accountLabel = accountLabel;
    
    [self addSubview:self.accountLabel];
    
    
    UILabel * emailLabel = [UILabel new];
    
    emailLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    emailLabel.textColor = ColorWithRGB(0xbebebe);
    emailLabel.text = @"bowen@163.com";
    
    self.emailLabel = emailLabel;
    
    [self addSubview:self.emailLabel];
    
    
    UIView * moneyView = [[UIView alloc] init];
    
    moneyView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"背景"]];
    
    self.moneyView = moneyView;
    
    [self addSubview:self.moneyView];
    
    
    UILabel * allMoneyLabel = [UILabel new];
    
    allMoneyLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    allMoneyLabel.textColor = ColorWithRGB(0xbebebe);
    allMoneyLabel.text = @"资产总额";
    
    self.allMoneyLabel = allMoneyLabel;
    
    [self addSubview:self.allMoneyLabel];
    
    
    UILabel * allMoneyCountLabel = [UILabel new];
    
    allMoneyCountLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:24 * SCREENH6];
    allMoneyCountLabel.textColor = ColorWithRGB(0xfd5c51);
    allMoneyCountLabel.text = @"$988";
    
    self.allMoneyCountLabel = allMoneyCountLabel;
    
    [self addSubview:self.allMoneyCountLabel];
    
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0x7d7c7c);
    
    self.lineView = lineView;
    
    [self addSubview:lineView];
    
    
    UILabel * userMoneyLabel = [UILabel new];
    
    userMoneyLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    userMoneyLabel.textColor = ColorWithRGB(0xbebebe);
    userMoneyLabel.text = @"交易可用资金";
    
    self.userMoneyLabel = userMoneyLabel;
    
    [self addSubview:self.userMoneyLabel];
    
    
    UILabel * userMoneyCountLabel = [UILabel new];
    
    userMoneyCountLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:24 * SCREENH6];
    userMoneyCountLabel.textColor = ColorWithRGB(0xfd5c51);
    userMoneyCountLabel.text = @"$988";
    
    self.userMoneyCountLabel = userMoneyCountLabel;
    
    [self addSubview:self.userMoneyCountLabel];
}



- (void)layoutSubviews{
    
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.mas_equalTo(self);
    }];
    
    
    [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self);
        make.height.mas_equalTo(100 * SCREENH6);
        make.top.mas_equalTo(self).offset(64 * SCREENH6);
    }];
    
    [self.userIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.topImageView).offset(9 * SCREENH6);
        make.width.height.mas_equalTo(55 * SCREENH6);
        make.leading.mas_equalTo(self).offset(15 * SCREENH6);
    }];
    
    [self.accountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.topImageView).offset(21 * SCREENH6);
        make.leading.mas_equalTo(self.userIconImageView.mas_trailing).offset(17 * SCREENH6);
    }];
    
    [self.emailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.accountLabel.mas_bottom).offset(10 * SCREENH6);
        make.leading.mas_equalTo(self.accountLabel);
    }];
    
    [self.moneyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.userIconImageView.mas_bottom).offset(15 * SCREENH6);
        make.centerX.mas_equalTo(self);
        make.width.mas_equalTo(345 * SCREENH6);
        make.height.mas_equalTo(65 * SCREENH6);
    }];
    
    [self.allMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.moneyView).offset(48 * SCREENH6);
        make.top.mas_equalTo(self.moneyView).offset(5 * SCREENH6);
    }];
    
    [self.allMoneyCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.allMoneyLabel);
        make.top.mas_equalTo(self.allMoneyLabel.mas_bottom).offset(4 * SCREENH6);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.width.mas_equalTo(1 * SCREENH6);
        make.height.mas_equalTo(25 * SCREENH6);
        make.centerY.mas_equalTo(self.moneyView);
    }];
    
    [self.userMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.lineView.mas_trailing).offset(50 * SCREENH6);
        make.top.mas_equalTo(self.allMoneyLabel);
    }];
    
    [self.userMoneyCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.userMoneyLabel);
        make.top.mas_equalTo(self.allMoneyCountLabel);
    }];
}

@end
